home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / workbench / directoryopus4 / dopus4_src / program / main17.c < prev    next >
C/C++ Source or Header  |  2000-03-11  |  55KB  |  1,513 lines

  1. /*
  2.  
  3. Directory Opus 4
  4. Original GPL release version 4.12
  5. Copyright 1993-2000 Jonathan Potter
  6.  
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. All users of Directory Opus 4 (including versions distributed
  22. under the GPL) are entitled to upgrade to the latest version of
  23. Directory Opus version 5 at a reduced price. Please see
  24. http://www.gpsoft.com.au for more information.
  25.  
  26. The release of Directory Opus 4 under the GPL in NO WAY affects
  27. the existing commercial status of Directory Opus 5.
  28.  
  29. */
  30.  
  31. #include "dopus.h"
  32.  
  33. static char maxlengths[6]={30,80,40,32,32,-1};
  34.  
  35. rexxdisp(msg,cmd,command)
  36. struct RexxMsg *msg;
  37. struct CommandList *cmd;
  38. char *command;
  39. {
  40.     int a,b,c,d,f,val,function,win,statval,retval,x,y,w,h;
  41.     char buf[520],*buf1,pad[8],buf2[10],*buf3,*ptr,ch,*retbuf;
  42.     BPTR lock;
  43.     struct DateStamp ds;
  44.     struct dopusgadgetbanks *bank;
  45.     struct Directory *entry;
  46.     unsigned char cval;
  47.     struct dopusfiletype *ftype;
  48.     struct DirectoryWindow *dirwin;
  49.  
  50.     buf[0]=0;
  51.     if (cmd) func_global_function=cmd->function;
  52.     for (a=0;a<16;a++) {
  53.         rexx_args[a][0]=0;
  54.         rexx_arg_value[a]=0;
  55.     }
  56.  
  57.     if (!command || !command[0]) rexx_argcount=0;
  58.     else rexx_argcount=parse(command);
  59.  
  60.     for (a=0;a<rexx_argcount;a++) {
  61.         for (b=0;b<256;b++) {
  62.             if ((ch=rexx_args[a][b])==0) break;
  63.             if (ch==(char)160) rexx_args[a][b]=' ';
  64.         }
  65.     }
  66.  
  67.     if (rexx_argcount==0 && func_global_function!=FUNC_PRINT) rexx_global_flag=0;
  68.     else {
  69.         rexx_global_flag=1;
  70.         switch (func_global_function) {
  71.             case FUNC_ERRORHELP:
  72.                 rexx_arg_value[0]=atoi(rexx_args[0]);
  73.                 return(0);
  74.             case FUNC_PROTECT:
  75.                 rexx_arg_value[0]=getprotval(rexx_args[1]);
  76.                 if (rexx_argcount>2) rexx_arg_value[1]=getprotval(rexx_args[2])^15;
  77.                 else rexx_arg_value[1]=0;
  78.                 return(0);
  79.             case FUNC_SELECT:
  80.                 rexx_arg_value[0]=1;
  81.                 for (a=0;a<rexx_argcount;a++) {
  82.                     if ((LStrCmpI(rexx_args[a],"onlyfiles"))==0) rexx_arg_value[0]=2;
  83.                     else if ((LStrCmpI(rexx_args[a],"onlydirs"))==0) rexx_arg_value[0]=3;
  84.                     else if ((LStrCmpI(rexx_args[a],"name"))==0) rexx_arg_value[1]=0;
  85.                     else if ((LStrCmpI(rexx_args[a],"date"))==0) rexx_arg_value[1]=1;
  86.                     else if ((LStrCmpI(rexx_args[a],"protection"))==0) rexx_arg_value[1]=2;
  87.                 }
  88.                 return(0);
  89.             case FUNC_SEARCH:
  90.                 if (rexx_argcount>2) {
  91.                     search_flags=SEARCH_NOCASE;
  92.                     for (a=2;a<rexx_argcount;a++) {
  93.                         if ((LStrCmpI(rexx_args[a],"ucnlc"))==0) search_flags&=~SEARCH_NOCASE;
  94.                         else if ((LStrCmpI(rexx_args[a],"wild"))==0) search_flags|=SEARCH_WILDCARD;
  95.                         else if ((LStrCmpI(rexx_args[a],"byword"))==0) search_flags|=SEARCH_ONLYWORDS;
  96.                     }
  97.                 }
  98.                 return(0);
  99.         }
  100.     }
  101.  
  102.     function=func_global_function;
  103.     func_global_function=0;
  104.     switch (function) {
  105.         case FUNC_SETVAR:
  106.             if (!system_version2) {
  107.                 rexx_set_return(msg,10,NULL);
  108.             }
  109.             else if (rexx_argcount<2) {
  110.                 rexx_set_return(msg,20,NULL);
  111.             }
  112.             else {
  113.                 int a;
  114.  
  115.                 buf[0]=0;
  116.                 for (a=1;a<rexx_argcount;a++) {
  117.                     StrConcat(buf,rexx_args[a],520);
  118.                     if (a<rexx_argcount-1) StrConcat(buf," ",520);
  119.                 }
  120.  
  121.                 if (SetVar(rexx_args[0],buf,-1,GVF_LOCAL_ONLY)) {
  122.                     rexx_set_return(msg,0,NULL);
  123.                 }
  124.                 else {
  125.                     rexx_set_return(msg,IoErr(),NULL);
  126.                 }
  127.             }
  128.             break;
  129.  
  130.         case FUNC_DEVICELIST:
  131.             if (rexx_argcount<1 ||
  132.                 (win=atoi(rexx_args[0]))<0 || win>1)
  133.                 win=data_active_window;
  134.             dodevicelist(win);
  135.             break;
  136.  
  137.         case FUNC_DISKINFO:
  138.             if (rexx_argcount<1) ptr=str_pathbuffer[data_active_window];
  139.             else ptr=rexx_args[0];
  140.             dodiskinfo(ptr);
  141.             break;
  142.  
  143.         case FUNC_VERIFY:
  144.         case FUNC_NOTIFY:
  145.             if (rexx_argcount) {
  146.                 ++command;
  147.                 do_title_string(command,buf,1,NULL);
  148.                 command=buf;
  149.             }
  150.             else if (function==FUNC_VERIFY) command=globstring[STR_REALLY_PROCEED];
  151.             else break;
  152.  
  153.             if (!(simplerequest(command,
  154.                 (function==FUNC_VERIFY)?str_okaystring:globstring[STR_CONTINUE],
  155.                 (function==FUNC_VERIFY)?str_cancelstring:NULL,
  156.                 NULL))) {
  157.                 status_flags|=STATUS_VERIFYFAIL;
  158.                 myabort();
  159.                 a=0;
  160.             }
  161.             else a=1;
  162.             rexx_return(msg,a);
  163.             return(1);
  164.  
  165.         case FUNC_CHECKABORT:
  166.             rexx_return(msg,status_rexxabort);
  167.             status_rexxabort=0;
  168.             return(1);
  169.  
  170.         case FUNC_SCANDIR:
  171.             if (rexx_argcount>0) {
  172.                 if (rexx_argcount<2 || (win=atoi(rexx_args[1]))<0 || win>1)
  173.                     win=data_active_window;
  174.                 strcpy(str_pathbuffer[win],rexx_args[0]);
  175.                 if (!status_iconified) startgetdir(win,SGDFLAGS_CANMOVEEMPTY|SGDFLAGS_CANCHECKBUFS);
  176.             }
  177.             break;
  178.  
  179.         case FUNC_CLEARWINDOW:
  180.             if (rexx_argcount<1 || (win=atoi(rexx_args[0]))<0 || win>1)
  181.                 win=data_active_window;
  182.             checkcurrentbuffer(win);
  183.             str_pathbuffer[win][0]=0;
  184.             dopus_curwin[win]->directory[0]=0;
  185.             checkdir(str_pathbuffer[win],&path_strgadget[win]);
  186.             freedir(dopus_curwin[win],win);
  187.             displaydir(win);
  188.             seename(win);
  189.             break;
  190.  
  191.         case FUNC_GETSTRING:
  192.             buf[0]=0;
  193.             if (rexx_argcount==0) command=globstring[STR_ENTER_A_STRING];
  194.             else {
  195.                 command=rexx_args[0];
  196.                 if (rexx_argcount>1) strcpy(buf,rexx_args[1]);
  197.             }
  198.             if (!(whatsit(command,256,buf,NULL))) rexx_set_return(msg,1,NULL);
  199.             else rexx_set_return(msg,0,buf);
  200.             if (!status_iconified) unbusy();
  201.             return(1);
  202.  
  203.         case FUNC_LOADCONFIG:
  204.             if (rexx_argcount>0 && checknewconfig() && checkwindowquit()) {
  205.                 busy();
  206.                 dostatustext(globstring[STR_READING_CONFIG]);
  207.                 shutthingsdown(0);
  208.                 strcpy(str_config_basename,rexx_args[0]);
  209.                 if ((ptr=strstri(BaseName(str_config_basename),".CFG"))) *ptr=0;
  210.                 read_configuration(0);
  211.                 SetUp(0);
  212.                 okay();
  213.             }
  214.             else a=0;
  215.             rexx_return(msg,a);
  216.             return(1);
  217.  
  218.         case FUNC_LOADSTRINGFILE:
  219.             if (rexx_argcount>0 && (CheckExist(rexx_args[0],NULL))<0) {
  220.                 busy();
  221.                 dostatustext(globstring[STR_READING_CONFIG]);
  222.                 readstrings(rexx_args[0]);
  223.                 okay();
  224.                 a=1;
  225.             }
  226.             else a=0;
  227.             rexx_return(msg,a);
  228.             return(1);
  229.  
  230.         case FUNC_REQUEST:
  231.             if (rexx_argcount==0) command=globstring[STR_PLEASE_CHOOSE];
  232.             else ++command;
  233.             rexx_return(msg,(simplerequest(command,str_okaystring,str_cancelstring,NULL)));
  234.             if (!status_iconified) unbusy();
  235.             return(1);
  236.  
  237.         case FUNC_DOPUSTOFRONT:
  238.             dopustofront();
  239.             break;
  240.  
  241.         case FUNC_DOPUSTOBACK:
  242.             dopustoback();
  243.             break;
  244.  
  245.         case FUNC_GETALL:
  246.         case FUNC_GETFILES:
  247.         case FUNC_GETDIRS:
  248.         case FUNC_GETSELECTEDALL:
  249.         case FUNC_GETSELECTEDFILES:
  250.         case FUNC_GETSELECTEDDIRS:
  251.             if (rexx_argcount<2 || (win=atoi(rexx_args[1]))<0 || win>1)
  252.                 win=data_active_window;
  253.             if (rexx_argcount<1) {
  254.                 pad[0]=' ';
  255.                 pad[1]=0;
  256.             }
  257.             else {
  258.                 LStrnCpy(pad,rexx_args[0],7);
  259.                 pad[7]=0;
  260.             }
  261.             val=strlen(pad);
  262.  
  263.             a=d=0;
  264.             switch (function) {
  265.                 case FUNC_GETSELECTEDALL:
  266.                     function=FUNC_GETALL; d=1;
  267.                     break;
  268.                 case FUNC_GETSELECTEDFILES:
  269.                     function=FUNC_GETFILES; d=1;
  270.                     break;
  271.                 case FUNC_GETSELECTEDDIRS:
  272.                     function=FUNC_GETDIRS; d=1;
  273.                     break;
  274.             }
  275.             entry=dopus_curwin[win]->firstentry;
  276.             while (entry) {
  277.                 if ((function==FUNC_GETALL ||
  278.                     (function==FUNC_GETFILES && entry->type<=ENTRY_FILE) ||
  279.                     (function==FUNC_GETDIRS && entry->type>=ENTRY_DIRECTORY)) &&
  280.                     (!d || entry->selected)) {
  281.                     if (entry->type!=ENTRY_CUSTOM || entry->subtype!=CUSTOMENTRY_USER)
  282.                         a+=strlen(entry->name)+val;
  283.                     else if (entry->size&CUSTENTRY_CANSELECT) a+=9+val;
  284.                 }
  285.                 entry=entry->next;
  286.             }
  287.             if (a>0) {
  288.                 if (buf1=AllocMem(a+2,MEMF_CLEAR)) {
  289.                     entry=dopus_curwin[win]->firstentry;
  290.                     while (entry) {
  291.                         if ((function==FUNC_GETALL ||
  292.                             (function==FUNC_GETFILES && entry->type<=ENTRY_FILE) ||
  293.                             (function==FUNC_GETDIRS && entry->type>=ENTRY_DIRECTORY)) && 
  294.                             (!d || entry->selected)) {
  295.                             if (entry->type!=ENTRY_CUSTOM || entry->subtype!=CUSTOMENTRY_USER ||
  296.                                 entry->size&CUSTENTRY_CANSELECT) {
  297.                                 LStrCat(buf1,entry->name);
  298.                                 LStrCat(buf1,pad);
  299.                             }
  300.                         }
  301.                         entry=entry->next;
  302.                     }
  303.                     rexx_set_return(msg,0,buf1);
  304.                     FreeMem(buf1,a+2);
  305.                 }
  306.                 else rexx_set_return(msg,10,NULL);
  307.             }
  308.             else rexx_set_return(msg,0,NULL);
  309.             return(1);
  310.  
  311.         case FUNC_GETNEXTSELECTED:
  312.             if (rexx_argcount<1 || (win=atoi(rexx_args[0]))<0 || win>1)
  313.                 win=data_active_window;
  314.             entry=dopus_curwin[win]->firstentry;
  315.             while (entry) {
  316.                 if (entry->selected) {
  317.                     ptr=NULL;
  318.                     if (entry->type==ENTRY_CUSTOM) {
  319.                         if (entry->dispstr) ptr=entry->dispstr;
  320.                         else ptr=entry->comment;
  321.                     }
  322.                     if (!ptr) ptr=entry->name;
  323.                     rexx_set_return(msg,0,ptr);
  324.                     return(1);
  325.                 }
  326.                 entry=entry->next;
  327.             }
  328.             break;
  329.  
  330.         case FUNC_GETENTRY:
  331.             a=atoi(rexx_args[0]);
  332.             if (rexx_argcount<2 || (win=atoi(rexx_args[1]))<0 || win>1)
  333.                 win=data_active_window;
  334.             entry=dopus_curwin[win]->firstentry;
  335.             while (a && entry) {
  336.                 if (a==1) {
  337.                     ptr=NULL;
  338.                     if (entry->type==ENTRY_CUSTOM) {
  339.                         if (entry->dispstr) ptr=entry->dispstr;
  340.                         else ptr=entry->comment;
  341.                     }
  342.                     if (!ptr) ptr=entry->name;
  343.                     rexx_set_return(msg,0,ptr);
  344.                     return(1);
  345.                 }
  346.                 --a;
  347.                 entry=entry->next;
  348.             }
  349.             break;
  350.  
  351.         case FUNC_GETFILETYPE:
  352.             if ((ftype=checkfiletype(rexx_args[0],-1,0))) {
  353.                 if (rexx_args[1][0]=='1') strcpy(buf,ftype->typeid);
  354.                 else strcpy(buf,ftype->type);
  355.             }
  356.             else buf[0]=0;
  357.             rexx_set_return(msg,0,buf);
  358.             return(1);
  359.  
  360.         case FUNC_OTHERWINDOW:
  361.             makeactive(1-data_active_window,0);
  362.             rexx_return(msg,data_active_window);
  363.             global_swap_window=TRUE;
  364.             return(1);
  365.  
  366.         case FUNC_STATUS:
  367.             statval=atoi(rexx_args[0]);
  368.             d=0; buf1=buf3=NULL;
  369.             if ((LStrCmpI(rexx_args[1],"set"))==0) {
  370.                 f=1; c=0;
  371.                 val=atoi(rexx_args[2]); buf3=rexx_args[2];
  372.             }
  373.             else if ((LStrCmpI(rexx_args[2],"set"))==0) {
  374.                 c=atoi(rexx_args[1]);
  375.                 f=1;
  376.                 val=atoi(rexx_args[3]); buf3=rexx_args[3];
  377.             }
  378.             else {
  379.                 c=atoi(rexx_args[1]);
  380.                 f=0;
  381.             }
  382.             switch (statval) {
  383.                 case RXSTATUS_CURRENT_DIRECTORY:
  384.                     if (f) {
  385.                         if (!(lock=Lock(buf3,ACCESS_READ))) break;
  386.                         lock=CurrentDir(lock);
  387.                         UnLock(lock);
  388.                         break;
  389.                     }
  390.                     if (expand_path("",buf)) buf1=buf;
  391.                     break;
  392.                 case RXSTATUS_VERSION:
  393.                     buf1=str_version_string;
  394.                     break;
  395.                 case RXSTATUS_ACTIVE_WINDOW:
  396.                     if (f && !status_iconified) makeactive(val,0);
  397.                     else d=data_active_window;
  398.                     break;
  399.                 case RXSTATUS_NUMBER_OF_FILES:
  400.                     if (c<0 || c>1) c=data_active_window;
  401.                     d=dopus_curwin[c]->filetot;
  402.                     break;
  403.                 case RXSTATUS_NUMBER_OF_DIRS:
  404.                     if (c<0 || c>1) c=data_active_window;
  405.                     d=dopus_curwin[c]->dirtot;
  406.                     break;
  407.                 case RXSTATUS_NUMBER_OF_ENTRIES:
  408.                     if (c<0 || c>1) c=data_active_window;
  409.                     d=dopus_curwin[c]->total;
  410.                     break;
  411.                 case RXSTATUS_NUMBER_SELECTED_FILES:
  412.                     if (c<0 || c>1) c=data_active_window;
  413.                     d=dopus_curwin[c]->filesel;
  414.                     break;
  415.                 case RXSTATUS_NUMBER_SELECTED_DIRS:
  416.                     if (c<0 || c>1) c=data_active_window;
  417.                     d=dopus_curwin[c]->dirsel;
  418.                     break;
  419.                 case RXSTATUS_NUMBER_SELECTED_ENTRIES:
  420.                     if (c<0 || c>1) c=data_active_window;
  421.                     d=dopus_curwin[c]->filesel+dopus_curwin[c]->dirsel;
  422.                     break;
  423.                 case RXSTATUS_TOTAL_BYTES:
  424.                     if (c<0 || c>1) c=data_active_window;
  425.                     d=dopus_curwin[c]->bytestot;
  426.                     break;
  427.                 case RXSTATUS_TOTAL_SELECTED_BYTES:
  428.                     if (c<0 || c>1) c=data_active_window;
  429.                     d=dopus_curwin[c]->bytessel;
  430.                     break;
  431.                 case RXSTATUS_SELECT_PATTERN:
  432.                     if (f) strcpy(str_select_pattern[c],buf3);
  433.                     else buf1=str_select_pattern[c];
  434.                     break;
  435.                 case RXSTATUS_DIRECTORY_NAME:
  436.                     if (c<0 || c>1) c=data_active_window;
  437.                     if (f) {
  438.                         strcpy(str_pathbuffer[c],buf3);
  439.                         if (!status_iconified) startgetdir(c,0);
  440.                     }
  441.                     else buf1=str_pathbuffer[c];
  442.                     break;
  443.                 case RXSTATUS_DISK_NAME:
  444.                     if (c<0 || c>1) c=data_active_window;
  445.                     buf1=dopus_curwin[c]->diskname;
  446.                     break;
  447.                 case RXSTATUS_DISK_FREE_BYTES:
  448.                     if (c<0 || c>1) c=data_active_window;
  449.                     d=dopus_curwin[c]->diskfree;
  450.                     break;
  451.                 case RXSTATUS_DISK_TOTAL_BYTES:
  452.                     if (c<0 || c>1) c=data_active_window;
  453.                     d=dopus_curwin[c]->disktot;
  454.                     break;
  455.                 case RXSTATUS_BUFFERED_DIRECTORY_NAME:
  456.                 case RXSTATUS_BUFFERED_DISKNAME:
  457.                 case RXSTATUS_BUFFERED_DISK_FREE_BYTES:
  458.                 case RXSTATUS_BUFFERED_DISK_TOTAL_BYTES:
  459.                     if (c<0 || c>1) c=data_active_window;
  460.                     dirwin=dopus_firstwin[c];
  461.                     b=atoi(rexx_args[2]);
  462.                     for (a=0;a<b;a++) {
  463.                         if (!dirwin) break;
  464.                         dirwin=dirwin->next;
  465.                     }
  466.                     if (dirwin) {
  467.                         switch (statval) {
  468.                             case RXSTATUS_BUFFERED_DIRECTORY_NAME:
  469.                                 buf1=dirwin->directory;
  470.                                 break;
  471.                             case RXSTATUS_BUFFERED_DISKNAME:
  472.                                 buf1=dirwin->diskname;
  473.                                 break;
  474.                             case RXSTATUS_BUFFERED_DISK_FREE_BYTES:
  475.                                 d=dirwin->diskfree;
  476.                                 break;
  477.                             case RXSTATUS_BUFFERED_DISK_TOTAL_BYTES:
  478.                                 d=dirwin->disktot;
  479.                                 break;
  480.                         }
  481.                     }
  482.                     break;
  483.                 case RXSTATUS_BUFFER_DISPLAYED:
  484.                     if (c<0 || c>1) c=data_active_window;
  485.                     dirwin=dopus_firstwin[c];
  486.                     for (a=0;a<data_buffer_count[c];a++) {
  487.                         if (!dirwin || dirwin==dopus_curwin[c]) break;
  488.                         dirwin=dirwin->next;
  489.                     }
  490.                     if (dirwin) d=a;
  491.                     else d=-1;
  492.                     if (f && val>=0 && val<data_buffer_count[c]) {
  493.                         for (a=0;a<val;a++) {
  494.                             if (!dirwin) break;
  495.                             dirwin=dirwin->next;
  496.                         }
  497.                         if (dirwin && !status_iconified) go_to_buffer(c,dirwin);
  498.                     }
  499.                     break;
  500.                 case RXSTATUS_DISPLAY_OFFSET:
  501.                     if (c<0 || c>1) c=data_active_window;
  502.                     if (f) {
  503.                         dopus_curwin[c]->offset=val-1;
  504.                         if (dopus_curwin[c]->offset<0) dopus_curwin[c]->offset=0;
  505.                         else if (dopus_curwin[c]->offset>dopus_curwin[c]->total-scrdata_dispwin_lines)
  506.                             dopus_curwin[c]->offset=dopus_curwin[c]->total-scrdata_dispwin_lines;
  507.                         if (!status_iconified) {
  508.                             fixvertprop(c);
  509.                             displaydir(c);
  510.                         }
  511.                     }
  512.                     else d=dopus_curwin[c]->offset+1;
  513.                     break;
  514.                 case RXSTATUS_ENTRIES_PER_PAGE:
  515.                     d=scrdata_dispwin_lines;
  516.                     break;
  517.                 case RXSTATUS_CONFIGURATION_CHANGED:
  518.                     if (f) config_changed=val;
  519.                     else d=config_changed;
  520.                     break;
  521.                 case RXSTATUS_OKAY_STRING:
  522.                     if (f) strcpy(str_okaystring,buf3);
  523.                     else buf1=str_okaystring;
  524.                     break;
  525.                 case RXSTATUS_CANCEL_STRING:
  526.                     if (f) strcpy(str_cancelstring,buf3);
  527.                     else buf1=str_cancelstring;
  528.                     break;
  529.                 case RXSTATUS_ICONIFIED:
  530.                     d=status_iconified;
  531.                     break;
  532.                 case RXSTATUS_TOP_TEXT_JUSTIFY:
  533.                     if (f) {
  534.                         if (val>-1 && val<3) scrdata_statustext_pos=val;
  535.                     }
  536.                     else d=scrdata_statustext_pos;
  537.                     break;
  538.                 case RXSTATUS_CONFIGURATION_ADDRESS:
  539.                     lsprintf(buf,"%ld",config);
  540.                     buf1=buf;
  541.                     break;
  542.                 case RXSTATUS_FIRST_NODE:
  543.                     if (f) {
  544.                         if (c==0) dopus_firsttype=(struct dopusfiletype *)val;
  545.                         else if (c==1) {
  546.                             dopus_firstgadbank=(struct dopusgadgetbanks *)val;
  547.                             dopus_curgadbank=dopus_firstgadbank;
  548.                             data_gadgetrow_offset=0;
  549.                         }
  550.                         else if (c==2) dopus_firsthotkey=(struct dopushotkey *)val;
  551.                     }
  552.                     else {
  553.                         if (c==0) lsprintf(buf,"%ld",dopus_firsttype);
  554.                         else if (c==1) lsprintf(buf,"%ld",dopus_firstgadbank);
  555.                         else if (c==2) lsprintf(buf,"%ld",dopus_firsthotkey);
  556.                         buf1=buf;
  557.                     }
  558.                     break;
  559.                 case RXSTATUS_CURRENT_BANK_NUMBER:
  560.                     bank=dopus_firstgadbank;
  561.                     for (a=0;bank && bank!=dopus_curgadbank;a++) bank=bank->next;
  562.                     if (bank!=dopus_curgadbank) a=-1;
  563.                     lsprintf(buf,"%ld",a);
  564.                     buf1=buf;
  565.                     break;
  566.             }
  567.             if (buf1) rexx_set_return(msg,0,buf1);
  568.             else rexx_return(msg,d);
  569.             return(1);
  570.  
  571.         case FUNC_FILEINFO:
  572.             if (rexx_argcount==0) break;
  573.             if (rexx_argcount>1) pad[0]=rexx_args[1][0];
  574.             else pad[0]=' ';
  575.             if (rexx_argcount<3 || (win=atoi(rexx_args[2]))<0 || win>1)
  576.                 win=data_active_window;
  577.             if ((entry=findfile(dopus_curwin[win],rexx_args[0],NULL))) {
  578.                 getprot(entry->protection,buf2);
  579.                 lsprintf(buf,"%s%lc%ld%lc%ld%lc%ld%lc%ld%lc%ld%lc%ld%lc%s%lc%s%lc",
  580.                     entry->name,pad[0],entry->size,pad[0],entry->subtype,pad[0],
  581.                     entry->type,pad[0],entry->selected,pad[0],
  582.                     entry->date.ds_Days,pad[0],
  583.                     (entry->date.ds_Minute*60)+(entry->date.ds_Tick/50),pad[0],
  584.                     entry->comment,pad[0],buf2,pad[0]);
  585.                 rexx_set_return(msg,0,buf);
  586.                 return(1);
  587.             }
  588.             break;
  589.  
  590.         case FUNC_SCROLLV:
  591.             if (status_iconified || rexx_argcount<1) break;
  592.             if (rexx_argcount<2 ||
  593.                 (win=atoi(rexx_args[1]))<0 || win>1) win=data_active_window;
  594.  
  595.             dopus_curwin[win]->offset+=atoi(rexx_args[0]);
  596.             if (dopus_curwin[win]->offset>
  597.                 (dopus_curwin[win]->total-scrdata_dispwin_lines)) {
  598.                 dopus_curwin[win]->offset=
  599.                     dopus_curwin[win]->total-scrdata_dispwin_lines;
  600.             }
  601.             if (dopus_curwin[win]->offset<0) dopus_curwin[win]->offset=0;
  602.  
  603.             fixvertprop(win);
  604.             displaydir(win);
  605.             rexx_return(msg,dopus_curwin[win]->offset);
  606.             return(1);
  607.  
  608.         case FUNC_SCROLLH:
  609.             if (status_iconified || rexx_argcount<1) break;
  610.             if (rexx_argcount<2 ||
  611.                 (win=atoi(rexx_args[1]))<0 || win>1) win=data_active_window;
  612.  
  613.             dopus_curwin[win]->hoffset+=atoi(rexx_args[0]);
  614.             if (dopus_curwin[win]->hoffset>
  615.                 (dopus_curwin[win]->hlen-scrdata_dispwin_nchars[win])) {
  616.                 dopus_curwin[win]->hoffset=
  617.                     dopus_curwin[win]->hlen-scrdata_dispwin_nchars[win];
  618.             }
  619.             if (dopus_curwin[win]->hoffset<0) dopus_curwin[win]->hoffset=0;
  620.  
  621.             refreshwindow(win,1);
  622.             rexx_return(msg,dopus_curwin[win]->hoffset);
  623.             return(1);
  624.  
  625.         case FUNC_SCROLLTOSHOW:
  626.             if (status_iconified || rexx_argcount<1) break;
  627.             if (rexx_argcount<2 ||
  628.                 (win=atoi(rexx_args[1]))<0 || win>1) win=data_active_window;
  629.  
  630.             if (!(entry=findfile(dopus_curwin[win],rexx_args[0],NULL))) {
  631.                 if (isdigit(rexx_args[0][0])) {
  632.                     entry=dopus_curwin[win]->firstentry;
  633.                     a=atoi(rexx_args[0]);
  634.                     while (a-- && entry) entry=entry->next;
  635.                 }
  636.             }
  637.             if (entry) displaydirgiven(win,entry,1);
  638.             rexx_return(msg,(entry)?1:0);
  639.             return(1);
  640.  
  641.         case FUNC_NEXTDRIVES:
  642.             nextdrives();
  643.             break;
  644.  
  645.         case FUNC_PATTERNMATCH:
  646.             if (rexx_argcount<2) break;
  647.             LParsePatternI(rexx_args[0],buf);
  648.             rexx_return(msg,LMatchPatternI(buf,rexx_args[1]));
  649.             return(1);
  650.  
  651.         case FUNC_BUSY:
  652.             if (rexx_argcount<1 || status_iconified) break;
  653.             if ((LStrnCmpI(rexx_args[0],"on",2))==0) busy();
  654.             else if ((LStrnCmpI(rexx_args[0],"off",3))==0) unbusy();
  655.             break;
  656.  
  657.         case FUNC_SELECTENTRY:
  658.             if (rexx_argcount<1) break;
  659.             entry=dopus_curwin[data_active_window]->firstentry;
  660.             b=atoi(rexx_args[0]);
  661.             for (a=0;a<b;a++) {
  662.                 if (!entry) break;
  663.                 entry=entry->next;
  664.             }
  665.             if (!entry ||
  666.                 (entry->type==ENTRY_CUSTOM && entry->subtype==CUSTOMENTRY_USER &&
  667.                 !(entry->size&CUSTENTRY_CANSELECT))) {
  668.                 rexx_return(msg,-1);
  669.                 return(1);
  670.             }
  671.             goto doentryselection;
  672.         case FUNC_SELECTFILE:
  673.             if (status_iconified) strcpy(rexx_args[2],"0");
  674.             if (!(entry=findfile(dopus_curwin[data_active_window],rexx_args[0],NULL))) d=-1;
  675.             else {
  676. doentryselection:
  677.                 d=entry->selected;
  678.                 if (entry->selected) {
  679.                     if (entry->type>=ENTRY_DIRECTORY) {
  680.                         --dopus_curwin[data_active_window]->dirsel;
  681.                         if (entry->size!=-1) dopus_curwin[data_active_window]->bytessel-=entry->size;
  682.                     }
  683.                     else {
  684.                         --dopus_curwin[data_active_window]->filesel;
  685.                         dopus_curwin[data_active_window]->bytessel-=entry->size;
  686.                     }
  687.                 }
  688.                 if (rexx_argcount>1) a=atoi(rexx_args[1]);
  689.                 else a=-1;
  690.                 if (a==-1) a=1-entry->selected;
  691.                 entry->selected=a;
  692.                 if (entry->selected) {
  693.                     if (entry->type>=ENTRY_DIRECTORY) {
  694.                         ++dopus_curwin[data_active_window]->dirsel;
  695.                         if (entry->size!=-1) dopus_curwin[data_active_window]->bytessel+=entry->size;
  696.                     }
  697.                     else {
  698.                         ++dopus_curwin[data_active_window]->filesel;
  699.                         dopus_curwin[data_active_window]->bytessel+=entry->size;
  700.                     }
  701.                 }
  702.                 if (rexx_argcount>2 && atoi(rexx_args[2]) && !status_iconified) {
  703.                     refreshwindow(data_active_window,0);
  704.                     if (entry->type!=ENTRY_CUSTOM) doselinfo(data_active_window);
  705.                 }
  706.             }
  707.             rexx_return(msg,d);
  708.             return(1);
  709.  
  710.         case FUNC_DISPLAYDIR:
  711.             if (status_iconified) break;
  712.             if (rexx_argcount<1 || (win=atoi(rexx_args[0]))<0 || win>1)
  713.                 win=data_active_window;
  714.             refreshwindow(win,1);
  715.             break;
  716.  
  717.         case FUNC_ADDFILE:
  718.             a=atoi(rexx_args[3]);
  719.             if (a<0) a=0;
  720.             ds.ds_Days=a/86400; a%=86400;
  721.             ds.ds_Minute=a/60; a%=60;
  722.             ds.ds_Tick=a*50;
  723.  
  724.             if ((b=atoi(rexx_args[2]))==0) d=0;
  725.             else {
  726.                 if (status_iconified) strcpy(rexx_args[7],"0");
  727.                 d=addfile(dopus_curwin[data_active_window],data_active_window,
  728.                     rexx_args[0],
  729.                     atoi(rexx_args[1]),
  730.                     b,
  731.                     &ds,
  732.                     rexx_args[4],
  733.                     getprotval(rexx_args[5]),
  734.                     0,
  735.                     atoi(rexx_args[7]),
  736.                     NULL,NULL,0,0);
  737.                 fixprop(data_active_window);
  738.                 doposprop(data_active_window);
  739.             }
  740.             rexx_return(msg,d?1:0);
  741.             return(1);
  742.  
  743.         case FUNC_REMOVEFILE:
  744.             if (status_iconified) strcpy(rexx_args[1],"0");
  745.             if ((entry=findfile(dopus_curwin[data_active_window],rexx_args[0],NULL))) {
  746.                 removefile(entry,dopus_curwin[data_active_window],data_active_window,atoi(rexx_args[1]));
  747.                 a=1;
  748.             }
  749.             else a=0;
  750.             rexx_return(msg,a);
  751.             return(1);
  752.  
  753. /* AddCustEntry "text" <userdata> <fgpen> <bkpen> <selectable> <show> <before> */
  754.  
  755.         case FUNC_ADDCUSTENTRY:
  756.             if (status_iconified) strcpy(rexx_args[2],"0");
  757.             DateStamp(&ds);
  758.             buf2[0]=0;
  759.             if (dopus_curwin[data_active_window]->firstentry &&
  760.                 (dopus_curwin[data_active_window]->firstentry->type!=ENTRY_CUSTOM ||
  761.                 dopus_curwin[data_active_window]->firstentry->subtype!=CUSTOMENTRY_USER)) a=0;
  762.             else {
  763.                 if ((b=strlen(rexx_args[0]))>=MAXDISPLAYLENGTH) {
  764.                     b=MAXDISPLAYLENGTH-1;
  765.                     rexx_args[0][b]=0;
  766.                 }
  767.                 if (!dopus_curwin[data_active_window]->firstentry) {
  768.                     dopus_curwin[data_active_window]->hlen=scrdata_dispwin_nchars[data_active_window];
  769.                     fixhorizprop(data_active_window);
  770.                 }
  771.                 if (b>dopus_curwin[data_active_window]->hlen) {
  772.                     dopus_curwin[data_active_window]->hlen=b;
  773.                     fixhorizprop(data_active_window);
  774.                 }
  775.                 if (rexx_argcount>1) d=atoi(rexx_args[1]);
  776.                 else d=0;
  777.                 if (rexx_argcount>2) {
  778.                     cval=atoi(rexx_args[2]);
  779.                     c=cval;
  780.                 }
  781.                 else c=0x000000ff;
  782.                 if (rexx_argcount>3) {
  783.                     cval=atoi(rexx_args[3]);
  784.                     c|=cval<<8;
  785.                 }
  786.                 else c|=0x0000ff00;
  787.                 if (rexx_args[0][0] && rexx_argcount>4 && atoi(rexx_args[4])) c|=CUSTENTRY_CANSELECT;
  788.                 entry=NULL;
  789.                 if (rexx_argcount>6) {
  790.                     if ((f=atoi(rexx_args[6]))>-1) {
  791.                         entry=dopus_curwin[data_active_window]->firstentry;
  792.                         while (entry) {
  793.                             if (f--==0) break;
  794.                             entry=entry->next;
  795.                         }
  796.                         if (entry->last) entry=entry->last;
  797.                         else entry=(struct Directory *)-1;
  798.                     }
  799.                 }
  800.                 if ((a=addfile(dopus_curwin[data_active_window],
  801.                     data_active_window,buf2,c,ENTRY_CUSTOM,
  802.                     &ds,rexx_args[0],d,CUSTOMENTRY_USER,
  803.                     (rexx_argcount>5)?atoi(rexx_args[5]):0,NULL,entry,0,0))) {
  804.                     if (b>dopus_curwin[data_active_window]->hlen) dopus_curwin[data_active_window]->hlen=b;
  805.                 }
  806.             }
  807.             rexx_return(msg,a?1:0);
  808.             return(1);
  809.  
  810.         case FUNC_REMOVEENTRY:
  811.             if (rexx_argcount<1) break;
  812.             if (status_iconified) strcpy(rexx_args[1],"0");
  813.             entry=dopus_curwin[data_active_window]->firstentry;
  814.             b=atoi(rexx_args[0]);
  815.             for (a=0;a<b;a++) {
  816.                 if (!entry) break;
  817.                 entry=entry->next;
  818.             }
  819.             if (!entry) a=0;
  820.             else {
  821.                 removefile(entry,dopus_curwin[data_active_window],data_active_window,atoi(rexx_args[1]));
  822.                 a=1;
  823.             }
  824.             rexx_return(msg,a);
  825.             return(1);
  826.  
  827.         case FUNC_SETWINTITLE:
  828.             if (rexx_argcount<2 || (win=atoi(rexx_args[1]))<0 || win>1)
  829.                 win=data_active_window;
  830.             LStrnCpy(dopus_curwin[win]->diskname,rexx_args[0],32);
  831.             dopus_curwin[win]->diskfree=
  832.                 dopus_curwin[win]->disktot=
  833.                 dopus_curwin[win]->diskblock=-1;
  834.             if (!status_iconified) displayname(win,1);
  835.             break;
  836.  
  837.         case FUNC_ADDCUSTHANDLER:
  838.             if (rexx_argcount<2 || (win=atoi(rexx_args[1]))<0 || win>1)
  839.                 win=data_active_window;
  840.             strcpy(buf,dopus_curwin[win]->custhandler);
  841.             LStrnCpy(dopus_curwin[win]->custhandler,rexx_args[0],32);
  842.             rexx_set_return(msg,0,buf);
  843.             return(1);
  844.  
  845.         case FUNC_COPYWINDOW:
  846.             if (status_iconified) break;
  847.             if (rexx_argcount<1 || (win=atoi(rexx_args[0]))<0 || win>1)
  848.                 win=data_active_window;
  849.             copydirwin(dopus_curwin[win],dopus_curwin[1-win],1-win);
  850.             break;
  851.  
  852.         case FUNC_SWAPWINDOW:
  853.             if (status_iconified) break;
  854.             swapdirwin();
  855.             break;
  856.  
  857.         case FUNC_TOPTEXT:
  858.             if (status_iconified) break;
  859.             if (rexx_argcount>0) dostatustext(command+1);
  860.             break;
  861.  
  862.         case FUNC_DIRTREE:
  863.             if (status_iconified) break;
  864.             if (rexx_argcount<1 || (win=atoi(rexx_args[0]))<0 || win>1)
  865.                 win=data_active_window;
  866.             dotree(win);
  867.             break;
  868.  
  869.         case FUNC_MODIFY:
  870.         case FUNC_QUERY:
  871.             if (rexx_argcount<1) break;
  872.             for (val=0;;val++) {
  873.                 if (modifynames[val][0]==0) {
  874.                     val=-1;
  875.                     break;
  876.                 }
  877.                 if (LStrCmpI(modifynames[val],rexx_args[0])==0) break;
  878.             }
  879.             b=atoi(rexx_args[1]);
  880.  
  881.             if (function==FUNC_QUERY) {
  882.                 retval=0;
  883.                 retbuf=NULL;
  884.  
  885.                 switch (val) {
  886.                     case MOD_COPYFLAGS:
  887.                         retval=config->copyflags;
  888.                         break;
  889.  
  890.                     case MOD_DELETEFLAGS:
  891.                         retval=config->deleteflags;
  892.                         break;
  893.  
  894.                     case MOD_ERRORFLAGS:
  895.                         retval=config->errorflags;
  896.                         break;
  897.  
  898.                     case MOD_LISTFORMAT:
  899.                         buf[0]=0;
  900.                         if (b<0 || b>1) b=data_active_window;
  901.                         for (a=0;a<=DISPLAY_LAST;a++) {
  902.                             if (config->displaypos[b][a]==-1) break;
  903.                             lsprintf(buf2,"%ld ",config->displaypos[b][a]);
  904.                             strcat(buf,buf2);
  905.                         }
  906.                         retbuf=buf;
  907.                         break;
  908.  
  909.                     case MOD_GENERALFLAGS:
  910.                         retval=config->generalflags;
  911.                         break;
  912.  
  913.                     case MOD_ICONFLAGS:
  914.                         retval=config->iconflags;
  915.                         break;
  916.  
  917.                     case MOD_REPLACEFLAGS:
  918.                         retval=config->existflags;
  919.                         break;
  920.  
  921.                     case MOD_SORTFLAGS:
  922.                         retval=config->sortflags;
  923.                         break;
  924.  
  925.                     case MOD_UPDATEFLAGS:
  926.                         retval=config->dynamicflags;
  927.                         break;
  928.  
  929.                     case MOD_SCRDEPTH:
  930.                         retval=config->scrdepth;
  931.                         break;
  932.  
  933.                     case MOD_SCREENFLAGS:
  934.                         retval=config->screenflags;
  935.                         break;
  936.  
  937.                     case MOD_SCREENMODE:
  938.                         retval=config->screenmode;
  939.                         break;
  940.  
  941.                     case MOD_SCRW:
  942.                         retval=config->scrw;
  943.                         break;
  944.  
  945.                     case MOD_SCRH:
  946.                         retval=config->scrh;
  947.                         break;
  948.  
  949.                     case MOD_DIRFLAGS:
  950.                         retval=config->dirflags;
  951.                         break;
  952.  
  953.                     case MOD_DEFAULTTOOL:
  954.                         retbuf=config->defaulttool;
  955.                         break;
  956.  
  957.                     case MOD_SHOWDELAY:
  958.                         retval=config->showdelay;
  959.                         break;
  960.  
  961.                     case MOD_VIEWPLAYFLAGS:
  962.                         retval=config->viewbits;
  963.                         break;
  964.  
  965.                     case MOD_FADETIME:
  966.                         retval=config->fadetime;
  967.                         break;
  968.  
  969.                     case MOD_HIDDENBIT:
  970.                         retval=config->hiddenbit;
  971.                         break;
  972.  
  973.                     case MOD_SHOWPATTERN:
  974.                         retbuf=config->showpat;
  975.                         break;
  976.  
  977.                     case MOD_HIDEPATTERN:
  978.                         retbuf=config->hidepat;
  979.                         break;
  980.  
  981.                     case MOD_ICONIFYFLAGS:
  982.                         retval=config->icontype;
  983.                         break;
  984.  
  985.                     case MOD_SCREENCLOCKFLAGS:
  986.                         retval=config->scrclktype;
  987.                         break;
  988.  
  989.                     case MOD_SHOWFREEFLAGS:
  990.                         retval=config->showfree;
  991.                         break;
  992.  
  993.                     case MOD_FONT:
  994.                         if (b<0 || b>=NUMFONTS) break;
  995.                         lsprintf(buf,"%s/%ld",config->fontbufs[b],config->fontsizes[b]);
  996.                         retbuf=buf;
  997.                         break;
  998.  
  999.                     case MOD_BANKNUMBER:
  1000.                         bank=dopus_firstgadbank;
  1001.                         for (a=0;bank && bank!=dopus_curgadbank;a++) bank=bank->next;
  1002.                         retval=a+1;
  1003.                         break;
  1004.  
  1005.                     case MOD_DATEFORMAT:
  1006.                         retval=config->dateformat;
  1007.                         break;
  1008.  
  1009.                     case MOD_GADGETROWS:
  1010.                         retval=config->gadgetrows;
  1011.                         break;
  1012.  
  1013.                     case MOD_DISPLAYLENGTH:
  1014.                         buf[0]=0;
  1015.                         if (b<0 || b>1) b=data_active_window;
  1016.                         for (a=0;a<5;a++) {
  1017.                             lsprintf(buf2,"%ld ",config->displaylength[b][a]);
  1018.                             strcat(buf,buf2);
  1019.                         }
  1020.                         retbuf=buf;
  1021.                         break;
  1022.  
  1023.                     case MOD_WINDOWDELTA:
  1024.                         retval=config->windowdelta;
  1025.                         break;
  1026.  
  1027.                     case MOD_SORTMETHOD:
  1028.                         if (b<0 || b>1) b=data_active_window;
  1029.                         retval=config->sortmethod[b];
  1030.                         break;
  1031.  
  1032.                     case MOD_SEPARATEMETHOD:
  1033.                         if (b<0 || b>1) b=data_active_window;
  1034.                         retval=config->separatemethod[b];
  1035.                         break;
  1036.  
  1037.                     case MOD_FILTER:
  1038.                         retbuf=str_filter;
  1039.                         break;
  1040.  
  1041.                     case MOD_WINDOWXY:
  1042.                         if (!status_iconified && status_publicscreen && Window)
  1043.                             lsprintf(buf,"%ld %ld",Window->LeftEdge,Window->TopEdge);
  1044.                         else lsprintf(buf,"%ld %ld",config->wbwinx,config->wbwiny);
  1045.                         retbuf=buf;
  1046.                         break;
  1047.  
  1048.                     case MOD_WINDOWSIZE:
  1049.                         if (!status_iconified && status_publicscreen && Window)
  1050.                             lsprintf(buf,"%ld %ld",Window->Width,Window->Height);
  1051.                         else lsprintf(buf,"%ld %ld",config->scr_winw,config->scr_winh);
  1052.                         retbuf=buf;
  1053.                         break;
  1054.  
  1055.                     case MOD_PUBSCREEN:
  1056.                         retbuf=config->pubscreen_name;
  1057.                         break;
  1058.  
  1059.                     case MOD_WINDOWXYWH:
  1060.                         if (!status_iconified && status_publicscreen && Window) {
  1061.                             lsprintf(buf,"%ld %ld %ld %ld",
  1062.                                 Window->LeftEdge,Window->TopEdge,Window->Width,Window->Height);
  1063.                         }
  1064.                         else {
  1065.                             lsprintf(buf,"%ld %ld %ld %ld",
  1066.                                 config->wbwinx,config->wbwiny,config->scr_winw,config->scr_winh);
  1067.                         }
  1068.                         retbuf=buf;
  1069.                         break;
  1070.  
  1071.                     case MOD_SCREENNAME:
  1072.                         retbuf=get_our_pubscreen();
  1073.                         break;
  1074.  
  1075.                     case MOD_PORTNAME:
  1076.                         retbuf=str_arexx_portname;
  1077.                         break;
  1078.                 }
  1079.  
  1080.                 if (retbuf) rexx_set_return(msg,0,retbuf);
  1081.                 else rexx_return(msg,retval);
  1082.                 return(1);
  1083.             }
  1084.  
  1085.             switch (val) {
  1086.                 case MOD_COPYFLAGS:
  1087.                     modify(&config->copyflags);
  1088.                     break;
  1089.  
  1090.                 case MOD_DELETEFLAGS:
  1091.                     modify(&config->deleteflags);
  1092.                     break;
  1093.  
  1094.                 case MOD_ERRORFLAGS:
  1095.                     modify(&config->errorflags);
  1096.                     break;
  1097.  
  1098.                 case MOD_LISTFORMAT:
  1099.                     if (b<0 || b>1) b=data_active_window;
  1100.                     for (a=0;a<=DISPLAY_LAST;a++) {
  1101.                         if (rexx_argcount<=a+2) config->displaypos[b][a]=-1;
  1102.                         else config->displaypos[b][a]=atoi(rexx_args[a+2]);
  1103.                     }
  1104.                     break;
  1105.  
  1106.                 case MOD_GENERALFLAGS:
  1107.                     modify(&config->generalflags);
  1108.                     break;
  1109.  
  1110.                 case MOD_ICONFLAGS:
  1111.                     modify(&config->iconflags);
  1112.                     break;
  1113.  
  1114.                 case MOD_REPLACEFLAGS:
  1115.                     modify(&config->existflags);
  1116.                     break;
  1117.  
  1118.                 case MOD_SORTFLAGS:
  1119.                     modify(&config->sortflags);
  1120.                     break;
  1121.  
  1122.                 case MOD_UPDATEFLAGS:
  1123.                     modify(&config->dynamicflags);
  1124.                     break;
  1125.  
  1126.                 case MOD_SCRDEPTH:
  1127.                     if (b<2) b=2;
  1128.                     else if (b>4) b=4;
  1129.                     config->scrdepth=b;
  1130.                     break;
  1131.  
  1132.                 case MOD_SCREENFLAGS:
  1133.                     modify(&config->screenflags);
  1134.                     break;
  1135.  
  1136.                 case MOD_SCREENMODE:
  1137.                     config->screenmode=b;
  1138.                     break;
  1139.  
  1140.                 case MOD_SCRW:
  1141.                     config->scrw=b;
  1142.                     break;
  1143.  
  1144.                 case MOD_SCRH:
  1145.                     config->scrh=b;
  1146.                     break;
  1147.  
  1148.                 case MOD_DIRFLAGS:
  1149.                     modify(&config->dirflags);
  1150.                     break;
  1151.  
  1152.                 case MOD_HELPFILE:
  1153.                     readhelp(rexx_args[1]);
  1154.                     break;
  1155.  
  1156.                 case MOD_DEFAULTTOOL:
  1157.                     strcpy(config->defaulttool,rexx_args[1]);
  1158.                     break;
  1159.  
  1160.                 case MOD_SHOWDELAY:
  1161.                     config->showdelay=b;
  1162.                     break;
  1163.  
  1164.                 case MOD_VIEWPLAYFLAGS:
  1165.                     modify(&config->viewbits);
  1166.                     break;
  1167.  
  1168.                 case MOD_FADETIME:
  1169.                     config->fadetime=b;
  1170.                     break;
  1171.  
  1172.                 case MOD_HIDDENBIT:
  1173.                     modify(&config->hiddenbit);
  1174.                     break;
  1175.  
  1176.                 case MOD_SHOWPATTERN:
  1177.                     strcpy(config->showpat,rexx_args[1]);
  1178.                     LParsePatternI(config->showpat,config->showpatparsed);
  1179.                     break;
  1180.  
  1181.                 case MOD_HIDEPATTERN:
  1182.                     strcpy(config->hidepat,rexx_args[1]);
  1183.                     LParsePatternI(config->hidepat,config->hidepatparsed);
  1184.                     break;
  1185.  
  1186.                 case MOD_ICONIFYFLAGS:
  1187.                     modify(&config->icontype);
  1188.                     break;
  1189.  
  1190.                 case MOD_SCREENCLOCKFLAGS:
  1191.                     modify(&config->scrclktype);
  1192.                     break;
  1193.  
  1194.                 case MOD_SHOWFREEFLAGS:
  1195.                     modify(&config->showfree);
  1196.                     break;
  1197.  
  1198.                 case MOD_FONT:
  1199.                     if (b<0 || b>=NUMFONTS) break;
  1200.                     strcpy(config->fontbufs[b],rexx_args[2]);
  1201.                     if (!strstri(config->fontbufs[b],".font"))
  1202.                         strcat(config->fontbufs[b],".font");
  1203.                     if (rexx_argcount>3) config->fontsizes[b]=atoi(rexx_args[3]);
  1204.                     break;
  1205.  
  1206.                 case MOD_BANKNUMBER:
  1207.                     bank=dopus_firstgadbank;
  1208.                     if ((--b)<0) b=0;
  1209.                     for (a=0;a<b;a++) {
  1210.                         if (!bank) break;
  1211.                         bank=bank->next;
  1212.                     }
  1213.                     if (bank && bank!=dopus_curgadbank) {
  1214.                         dopus_curgadbank=bank;
  1215.                         data_gadgetrow_offset=0;
  1216.                         drawgadgets(0,0);
  1217.                         fixgadgetprop();
  1218.                     }
  1219.                     break;
  1220.  
  1221.                 case MOD_DATEFORMAT:
  1222.                     modify(&config->dateformat);
  1223.                     break;
  1224.  
  1225.                 case MOD_GADGETROWS:
  1226.                     if (b<0 || b>6 || b==4 || b==5) break;
  1227.                     config->gadgetrows=b;
  1228.                     break;
  1229.  
  1230.                 case MOD_DISPLAYLENGTH:
  1231.                     if (b<0 || b>1) b=data_active_window;
  1232.                     for (a=0;a<8;a++) {
  1233.                         if (rexx_argcount<=a+2 || maxlengths[a]==-1) break;
  1234.                         config->displaylength[b][a]=atoi(rexx_args[a+2]);
  1235.                         if (config->displaylength[b][a]<5) config->displaylength[b][a]=5;
  1236.                         else if (config->displaylength[b][a]>maxlengths[a])
  1237.                             config->displaylength[b][a]=maxlengths[a];
  1238.                     }
  1239.                     break;
  1240.  
  1241.                 case MOD_WINDOWDELTA:
  1242.                     dosizedirwindows(b);
  1243.                     break;
  1244.  
  1245.                 case MOD_SORTMETHOD:
  1246.                     if (b<0 || b>1) b=data_active_window;
  1247.                     config->sortmethod[b]=atoi(rexx_args[2]);
  1248.                     break;
  1249.  
  1250.                 case MOD_SEPARATEMETHOD:
  1251.                     if (b<0 || b>1) b=data_active_window;
  1252.                     config->separatemethod[b]=atoi(rexx_args[2]);
  1253.                     break;
  1254.  
  1255.                 case MOD_FILTER:
  1256.                     strcpy(str_filter,rexx_args[1]);
  1257.                     if (str_filter[0]) {
  1258.                         screen_gadgets[SCRGAD_TINYFILTER].Flags|=GFLG_SELECTED;
  1259.                         LParsePatternI(str_filter,str_filter_parsed);
  1260.                     }
  1261.                     else {
  1262.                         screen_gadgets[SCRGAD_TINYFILTER].Flags&=~GFLG_SELECTED;
  1263.                         str_filter_parsed[0]=0;
  1264.                     }
  1265.                     if (Window && config->generalscreenflags&SCR_GENERAL_TINYGADS)
  1266.                         dolittlegads(&screen_gadgets[SCRGAD_TINYFILTER],&globstring[STR_TINY_BUTTONS][6],1);
  1267.                     break;
  1268.  
  1269.                 case MOD_WINDOWXY:
  1270.                     if (rexx_argcount<2) {
  1271.                         x=config->wbwinx;
  1272.                         y=config->wbwiny;
  1273.                     }
  1274.                     else {
  1275.                         if (b>-1) x=config->wbwinx=b;
  1276.                         else if (Window) x=Window->LeftEdge;
  1277.  
  1278.                         if (rexx_argcount>2 && (b=atoi(rexx_args[2]))>-1) y=config->wbwiny=b;
  1279.                         else if (Window) y=config->wbwiny=Window->TopEdge;
  1280.                     }
  1281.                     if (!status_iconified && status_publicscreen && Window) {
  1282.                         if (Window->Width+x>Window->WScreen->Width)
  1283.                             x=Window->WScreen->Width-Window->Width;
  1284.                         if (x<0) x=0;
  1285.                         if (Window->Height+y>Window->WScreen->Height)
  1286.                             y=Window->WScreen->Height-Window->Height;
  1287.                         if (y<0) y=0;
  1288.                         MoveWindow(Window,x-Window->LeftEdge,y-Window->TopEdge);
  1289.                     }
  1290.                     break;
  1291.  
  1292.                 case MOD_WINDOWSIZE:
  1293.                     if (rexx_argcount<2) {
  1294.                         w=config->scr_winw;
  1295.                         h=config->scr_winh;
  1296.                     }
  1297.                     else {
  1298.                         if (b>-1) w=config->scr_winw=b;
  1299.                         else if (Window) w=Window->Width;
  1300.  
  1301.                         if (rexx_argcount>2 && (b=atoi(rexx_args[2]))>-1) h=config->scr_winh=b;
  1302.                         else if (Window) h=config->scr_winh=Window->Height;
  1303.                     }
  1304.                     if (!status_iconified && status_publicscreen && Window) {
  1305.                         int dx=0,dy=0;
  1306.  
  1307.                         if (w<scr_min_width) w=scr_min_width;
  1308.                         else if (w>Window->WScreen->Width) w=Window->WScreen->Width;
  1309.                         if (h<scr_min_height) h=scr_min_height;
  1310.                         else if (h>Window->WScreen->Height) h=Window->WScreen->Height;
  1311.  
  1312.                         if (Window->LeftEdge+w>Window->WScreen->Width)
  1313.                             dx=(Window->WScreen->Width-w)-Window->LeftEdge;
  1314.  
  1315.                         if (Window->TopEdge+h>Window->WScreen->Height)
  1316.                             dy=(Window->WScreen->Height-h)-Window->TopEdge;
  1317.  
  1318.                         if (w!=Window->Width || h!=Window->Height) {
  1319.                             MoveWindow(Window,dx,dy);
  1320.                             SizeWindow(Window,w-Window->Width,h-Window->Height);
  1321.  
  1322.                             config->scr_winw=w;
  1323.                             config->scr_winh=h;
  1324.  
  1325.                             if (!MainScreen) {
  1326.                                 config->scrw=config->scr_winw;
  1327.                                 config->scrh=config->scr_winh;
  1328.                             }
  1329.                             config->screenflags&=~(SCRFLAGS_DEFWIDTH|SCRFLAGS_DEFHEIGHT);
  1330.                             remclock();
  1331.                             SetUp(0);
  1332.                             dostatustext(str_last_statustext);
  1333.                         }
  1334.                     }
  1335.                     break;
  1336.  
  1337.                 case MOD_PUBSCREEN:
  1338.                     strcpy(config->pubscreen_name,rexx_args[1]);
  1339.                     break;
  1340.  
  1341.                 case MOD_WINDOWXYWH:
  1342.                     if (rexx_argcount<4 || !system_version2) break;
  1343.                     config->wbwinx=b;
  1344.                     config->wbwiny=atoi(rexx_args[2]);
  1345.                     config->scr_winw=atoi(rexx_args[3]);
  1346.                     config->scr_winh=atoi(rexx_args[4]);
  1347.                     if (!status_iconified && status_publicscreen && Window)
  1348.                         ChangeWindowBox(Window,
  1349.                             config->wbwinx,config->wbwiny,
  1350.                             config->scr_winw,config->scr_winh);
  1351.                     break;
  1352.  
  1353.                 case MOD_PORTNAME:
  1354.                     change_port_name(rexx_args[1]);
  1355.                     break;
  1356.             }
  1357.             break;
  1358.  
  1359.         default:
  1360.             func_global_function=function;
  1361.             break;
  1362.     }
  1363.     if (!func_global_function) rexx_return(msg,0);
  1364.     return(0);
  1365. }
  1366.  
  1367. parse(buf)
  1368. char *buf;
  1369. {
  1370.     int len,argno,argpos,a,withinquote,havequoted;
  1371.  
  1372.     len=strlen(buf);
  1373.     for (a=len-1;a>=0;a--) if (!(isspace(buf[a]))) break;
  1374.     len=a;
  1375.     argno=argpos=withinquote=havequoted=0;
  1376.  
  1377.     for (a=1;a<=len;a++) {
  1378.         if (buf[a]=='\"') {
  1379.             if (withinquote==1) withinquote=0;
  1380.             else if (withinquote==0) {
  1381.                 withinquote=1;
  1382.                 havequoted=1;
  1383.             }
  1384.             else rexx_args[argno][argpos++]=buf[a];
  1385.         }
  1386.         else if (buf[a]=='\'') {
  1387.             if (withinquote==2) withinquote=0;
  1388.             else if (withinquote==0) {
  1389.                 withinquote=2;
  1390.                 havequoted=1;
  1391.             }
  1392.             else rexx_args[argno][argpos++]=buf[a];
  1393.         }
  1394.         else if (isspace(buf[a])) {
  1395.             if (withinquote) rexx_args[argno][argpos++]=buf[a];
  1396.             else {
  1397.                 if (argpos>0 || havequoted) {
  1398.                     rexx_args[argno++][argpos]=0;
  1399.                     argpos=havequoted=0;
  1400.                 }
  1401.             }
  1402.         }
  1403.         else rexx_args[argno][argpos++]=buf[a];
  1404.         if (argpos==255) {
  1405.             rexx_args[argno++][255]=0;
  1406.             argpos=havequoted=0;
  1407.         }
  1408.         if (argno==16) break;
  1409.     }
  1410.     if (argno<16 && argpos<256) rexx_args[argno][argpos]=0;
  1411.     else if (argno==16) argno=15;
  1412. /*
  1413.     if (rexx_args[0][0]==0) argno=-1;
  1414. */
  1415.     return(argno+1);
  1416. }
  1417.  
  1418. char *dosstatus(f,buf,buf1)
  1419. int f;
  1420. char *buf,*buf1;
  1421. {
  1422.     if (f) strcpy(buf,buf1);
  1423.     return(buf);
  1424. }
  1425.  
  1426. void dopustofront()
  1427. {
  1428.     int top;
  1429.  
  1430.     if (!status_iconified) {
  1431.         if (MainScreen) {
  1432.             ScreenToFront(MainScreen);
  1433.             if (!status_configuring && config->screenflags&SCRFLAGS_HALFHEIGHT)
  1434.                 top=scrdata_norm_height;
  1435.             else top=0;
  1436.             MoveScreen(MainScreen,0,top-MainScreen->TopEdge);
  1437.         }
  1438.         if (Window) {
  1439.             if (!Window->Flags&WFLG_BACKDROP) WindowToFront(Window);
  1440.             ActivateWindow(Window);
  1441.         }
  1442.     }
  1443. }
  1444.  
  1445. void dopustoback()
  1446. {
  1447.     if (!status_iconified) {
  1448.         if (MainScreen) ScreenToBack(MainScreen);
  1449.         else if (Window) WindowToBack(Window);
  1450.         if (Window->Parent) ActivateWindow(Window->Parent);
  1451.     }
  1452. }
  1453.  
  1454. checkkeyword(keywords,num,rem)
  1455. char **keywords;
  1456. int num,rem;
  1457. {
  1458.     int a;
  1459.  
  1460.     if (!keywords) return(0);
  1461.     for (a=0;;a++) {
  1462.         if (!keywords[a] || !keywords[a][0]) return(0);
  1463.         if (LStrCmpI(rexx_args[num],keywords[a])==0) {
  1464.             rexx_arg_value[a]=1;
  1465.             if (rem) removeargstring(num);
  1466.             return(1);
  1467.         }
  1468.     }
  1469.     return(0);
  1470. }
  1471.  
  1472. void removeargstring(num)
  1473. int num;
  1474. {
  1475.     int a;
  1476.  
  1477.     for (a=num+1;a<16;a++) {
  1478.         CopyMem(rexx_args[a],rexx_args[a-1],256);
  1479.         rexx_args[15][0]=0;
  1480.     }
  1481. }
  1482.  
  1483. void modify(flag)
  1484. char *flag;
  1485. {
  1486.     int a,b;
  1487.     char c;
  1488.  
  1489.     c=*flag;
  1490.     for (a=1;a<rexx_argcount;a++) {
  1491.         if (rexx_args[a][0]=='+') {
  1492.             b=atoi(&rexx_args[a][1]);
  1493.             c|=b;
  1494.         }
  1495.         else if (rexx_args[a][0]=='-') {
  1496.             b=atoi(&rexx_args[a][1]);
  1497.             c&=~b;
  1498.         }
  1499.         else c=b;
  1500.     }
  1501.     *flag=c;
  1502. }
  1503.  
  1504. void rexx_return(msg,num)
  1505. struct RexxMsg *msg;
  1506. int num;
  1507. {
  1508.     char numbuf[10];
  1509.  
  1510.     lsprintf(numbuf,"%ld",num);
  1511.     rexx_set_return(msg,0,numbuf);
  1512. }
  1513.